package com.x52im.rainbowchat.http.logic.pay.redenvelope;

import com.eva.framework.dbpool.DBDepend;
import com.eva.framework.dbpool.DBShell;
import com.x52im.rainbowchat.http.dao.MoneyDAO;
import com.x52im.rainbowchat.http.logic.dto.RedEnvelopeDTO;

import java.util.Vector;

public abstract class ARedEnvelope implements InfPay {
    DBShell db = new DBShell();
    MoneyDAO moneyDAO = new MoneyDAO();

    /**
     * 更新红包的状态
     */
    protected void updateRedEnvelope(RedEnvelopeDTO dto) throws Exception {
        Vector sqls = new Vector(1);
        Vector values = new Vector(1);
        sqls.add("UPDATE missu_red_envelope SET state=?, state_date=" + DBDepend.getDefaultDatetimeFunc() + " WHERE order_no=?");
        values.add(new Object[]{dto.getState(), dto.getOrderNo()});
        db.update(sqls, values, true);
    }

    protected String getMsg(Exception e) {
        String msg = e.getMessage();
        StringBuffer sbf = new StringBuffer(msg);
        sbf.setLength(999);
        return sbf.toString();
    }
}
